package Controller;

import service.EmpService;
import service.impl.EmpServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*
 *徐韬
 *2021/9/23
 *22:33
 */
@WebServlet("/delete")
public class deleteEmpController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        Integer id1 = Integer.valueOf(id);
        EmpService empService = new EmpServiceimpl();
        int i = empService.deleteEmp(id1);
        if(i>0){
            response.sendRedirect("/ems/ShowAllController");
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
